extends CanvasLayer

var technologies = []
var selected_tech: TechnologyResource

func _ready():
	# 从池中获取3个随机科技
	technologies = TechnologyManager.get_random_technologies(3, 3)
	
	# 初始化UI（根据新结构调整节点路径）
	for i in 3:
		# 更新路径到新的容器结构
		var option_container = $Panel/OptionsGrid.get_child(i)
		var tech = technologies[i]
		
		# 根据实际节点结构调整子节点路径（添加MarginContainer和VBoxContainer）
		var panel = option_container.get_node("MarginContainer/VBoxContainer")
		#panel.get_node("Icon").texture = tech.icon
		panel.get_node("Name").text = tech.display_name
		panel.get_node("Description").text = tech.description
		panel.get_node("SelectBtn").pressed.connect(_on_tech_selected.bind(tech))

func _on_tech_selected(tech: TechnologyResource):
	GameData.army_data.add_technology(tech)
	GameManager.save_game()
	get_tree().change_scene_to_file("res://game/01_scenes/interface/army_deployment/army_deployment.tscn")
